package vboot.core.module.ass.coge.form;

import vboot.core.common.api.R;
import vboot.core.common.dao.Sqler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("ass/coge/form")
public class AssCogeFormApi {

    @GetMapping
    public R get(String name) {
        Sqler sqler = new Sqler("ass_coge_form");
        sqler.addLike("t.name", name);
        return R.ok(service.findPageData(sqler));
    }


    @GetMapping("one/{id}")
    public R getOne(@PathVariable String id) {
        AssCogeForm main = service.findOne(id);
        return R.ok(main);
    }

    @PostMapping
    public R post(@RequestBody AssCogeForm main) {
        return R.ok(service.insert(main));
    }

    @PutMapping
    public R put(@RequestBody AssCogeForm main) {
        return R.ok(service.update(main));
    }

    @DeleteMapping("{ids}")
    public R delete(@PathVariable String[] ids) {
        return R.ok(service.delete(ids));
    }

    @Autowired
    private AssCogeFormService service;

}
